package minidb.parse.exps;

import java.util.*;

public class GroupList
{
	public List<Field> groupList;

	public GroupList()
	{
		this.groupList = new ArrayList<Field>();
	}

	public GroupList AddField(Field f)
	{
		this.groupList.add(f);
		return this;
	}

	public List<Field> GetGroupList()
	{
		return this.groupList;
	}

	public String Print()
	{
		StringBuilder sb = new StringBuilder("\nGROUP BY ");

		for (int i = 0; i < this.groupList.size(); i++)
		{
			Field f = this.groupList.get(i);
			sb.append(f.Print());
			if (i != this.groupList.size() - 1)
				sb.append(",");
		}
		return sb.toString();
	}
}
